<template>
  <div class="by-case-content">
    <avue-crud
      :option="options"
      v-model:search="search"
      v-model:page="page"
      v-model="form"
      :table-loading="loading"
      :data="data"
      ref="crud"
      @current-change="currentChange"
      @size-change="sizeChange"
      @refresh-change="refreshChange"
      @on-load="onLoad"
    ></avue-crud>
  </div>
</template>
<script setup>
import { listByCase } from '@/api/casemanagement/caseManagement';
import { EditPen, ArrowLeftBold } from '@element-plus/icons-vue';
import { findObject } from '@smallwei/avue';
import { ref, reactive, computed, onMounted, nextTick } from 'vue';
import { ElMessage, ElMessageBox } from 'element-plus';
import { useRoute } from 'vue-router';
import { useStore } from 'vuex';
const store = useStore();
const route = useRoute();
const routerQuery = ref({});
routerQuery.value = route.query;
const options = ref({
  height: 'auto',
  calcHeight: 30,
  tip: false,
  searchShow: true,
  searchMenuSpan: 24,
  searchMenuPosition: 'right',
  border: true,
  index: true,
  viewBtn: true,
  selection: true,
  dialogClickModal: false,
  align: 'center',
  indexWidth: 80,
  indexLabel: '编号',
  // menu: false,
  // addBtn: false,
  labelWidth: 145,
  viewBtn: false,
  editBtn: false,
  delBtn: false,
  addBtn:false,
  // menuWidth:300,
  menu:false,
  column:[
    {
      label: '业务名称',
      prop: "name",
      type: "input",
      width: 500,
    },
    {
      label: '病历名',
      prop: "name",
      type: "input",
    },
    {
      label: '主管医师',
      prop: "personInCharge",
      type: 'select',
      dicUrl: `/blade-system/user/user-list`,
      props: {
        label: 'realName',
        value: 'id',
      },
      filterable: true,
      overHidden: true,
    },
    {
      label: '业务状态',
      prop: "status",
      type: "select",
      dicData: [{
        label: '进行中',
        value: 1
      }, {
        label: '锁定',
        value: 2
      }],
    },
  ],
});
let form = ref({});
let data = ref([]);
let crud = ref(null);
const query = ref({});
const search = ref({});
let loading = ref(false);
const page = ref({
  pageSize: 10,
  currentPage: 1,
  total: 0,
});
const selectionList = ref([]);
const props = defineProps({
  caseManagementForm: {
    type: Object,
    default: {},
  }
});
const currentChange = currentPage => {
  page.value.currentPage = currentPage;
};

const sizeChange = pageSize => {
  page.value.pageSize = pageSize;
};

const refreshChange = () => {
  onLoad(page.value, query.value);
};

const onLoad = (page, params) => {
  loading.value = true;
  let values = {
    descs: 'create_time',
    caseId:routerQuery.value.caseManagementId,
    ...params,
  };
  listByCase(page.currentPage, page.pageSize, values).then(res => {
    const DATA = res.data.data;
    page.total = DATA.total;
    data.value = DATA.records;
    data.value.forEach(ele => {
      ele.name = props.caseManagementForm.name;
    });
    loading.value = false;
    // selectionClear();
  });
};
</script>
<style scoped>
.by-case-content {
  width: 100%;
  height: 100%;
}
</style>